<template>
  <GlobalHeader :user=currentUser />
  <div class="container">
    <Loader v-if="isLoading" text="玩命速递中..." background="rgba(0, 0, 0, .6)"></Loader>
    <RouterView></RouterView>
  </div>
  <Footer></Footer>
</template>

<script setup lang="ts">
import 'bootstrap/dist/css/bootstrap.min.css'
import { computed, watch } from 'vue'
import GlobalHeader from './components/GlobalHeader.vue'
import Footer from './views/Footer.vue'
import { RouterView } from 'vue-router'
import { useStore } from 'vuex'
import { GlobalDataProps } from './store'
import Loader from './components/Loader.vue'
import createMessage from './components/createMessage'

const store = useStore<GlobalDataProps>()
const currentUser = computed(() => store.state.user)
const isLoading = computed(() => store.state.loading)
const error = computed(() => store.state.error)

watch( () => error.value.status, () => {
  const { status, message } = error.value
  if (status && message) {
    createMessage(message, 'danger')
  }
})

</script>

<style scoped>

</style>
